<html>
<body>
	<form action="soap_call.php" method="post">
		<select name="func" id="func">
			<option value="string">getString</option>
			<option value="map">getMap</option>
		</select>
		<input type="submit" value="Call" />
	</form>

<?php
	if(isset($_POST['func'])){
		echo '<b>Result:</b><br>';
		require_once('wsTestServices.php');
		require_once('config.php');
		$soap_client = new WsTestServices($wsdl);
		try{
			if($_POST['func'] == 'string'){
			$input = new getString();
			$input->arg0 = 'test';
			$output = new getStringResponse();
			$output = $soap_client->getString($input);
			echo $output->return;
			}else{
				if($_POST['func'] == 'map'){
					$input = new getMap();
					$input->arg0->key='key';
					$input->arg0->value='value';
					$output = new getMapResponse();
					$output = $soap_client->getMap($input);

					if(count($output->return->entry) > 0){
						for($i = 0; $i < count($output->return->entry); $i++){
							echo "Map $i:<br>";
							echo "<i>key:</i> " . $output->return->entry[$i]->key . " ";
							echo "<i>value:</i> " . $output->return->entry[$i]->value . "<br>";
							echo "-------<br>";
						}
					}
				}
			}
		}catch(SoapFault $e){
			$error = $e->getMessage();
			$errno = $e->getCode();
			echo "<div><b>An error occurred:</b><br><pre><i>$error</i></pre></div>";
		};
	}


?>
</body>
</html>
